sp = input().split()
st = ''
for el in sp:
    if el == 'zero':
        st += '0'
    elif el == 'one':
        st += '1'
    elif el == 'two':
        st += '2'
    elif el == 'three':
        st += '3'
    elif el == 'four':
        st += '4'
    elif el == 'five':
        st += '5'
    elif el == 'six':
        st += '6'
    elif el == 'seven':
        st += '7'
    elif el == 'eight':
        st += '8'
    elif el == 'nine':
        st += '9'
    else:
        print('Wrong input')
        break
if len(st) == 3:
    n = int(st)
    num = 0
    flag = True
    while flag:
        nmin, nmax = n - num, n + num
        for i in range(2, nmin // 2 + nmin % 2 + 1):
            if nmin % i == 0:
                break
            if i == nmin // 2 + nmin % 2:
                print(nmin)
                flag = False
        for i in range(2, nmax // 2 + nmax % 2 + 1):
            if nmax % i == 0:
                break
            if i == nmax // 2 + nmax % 2:
                if flag:
                    print(nmax)
                    flag = False
        num += 1
